package top.chmin.project.cloud.common.code.template.auto;

// field import auto
// #bind.field.id#

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import top.chmin.project.cloud.common.entity.*;

/**
 * chmin
 * 2023-12-27 19:56:45
 * cloud-builder
 */
@Getter
@Setter
@Accessors(chain = true)
public class CodeTemplate extends Model {

    // field auto
// #bind.field.codeName#
    // 编码名称
    private String codeName;
// $bind.field.codeName$

    // #bind.field.prefix#
    // 编码前缀
    private String prefix;
// $bind.field.prefix$

    // #bind.field.codeDateTimeFormat#
    // 编码中的时间串格式
    private String codeDateTimeFormat;
// $bind.field.codeDateTimeFormat$

    // #bind.field.initValue#
    // 编码生成第一个值
    private Integer initValue;
// $bind.field.initValue$

    // #bind.field.minStep#
    // 步进最小值
    private Integer minStep;
// $bind.field.minStep$

    // #bind.field.maxStep#
    // 步进最大值
    private Integer maxStep;
// $bind.field.maxStep$

    // #bind.field.fixLength#
    // 编码补齐长度
    private Integer fixLength;
// $bind.field.fixLength$


    @Override
    public CodeTemplateEPC getPreCondition() {
        return new CodeTemplateEPC();
    }

    public class CodeTemplateEPC extends PreCondition {
        private CodeTemplateEPC() {
        }

        private CodeTemplateEPC(CodeTemplateEPC parent) {
            super(parent);
        }

        public CodeTemplateEPC forUpdate() {
            addUpdateSql("update_time = ?", updateTime);
            addUpdateSql("update_by = ?", updateBy);
// field update auto
// #bind.field.codeName#
            addUpdateSql("code_name = ?", codeName);
// $bind.field.codeName$

// #bind.field.prefix#
            addUpdateSql("prefix = ?", prefix);
// $bind.field.prefix$

// #bind.field.codeDateTimeFormat#
            addUpdateSql("code_date_time_format = ?", codeDateTimeFormat);
// $bind.field.codeDateTimeFormat$

// #bind.field.initValue#
            addUpdateSql("init_value = ?", initValue);
// $bind.field.initValue$

// #bind.field.minStep#
            addUpdateSql("min_step = ?", minStep);
// $bind.field.minStep$

// #bind.field.maxStep#
            addUpdateSql("max_step = ?", maxStep);
// $bind.field.maxStep$

// #bind.field.fixLength#
            addUpdateSql("fix_length = ?", fixLength);
// $bind.field.fixLength$

            type = "UPDATE";
            return this;
        }

        public CodeTemplateEPC forDelete() {
            type = "DELETE";
            return this;
        }

        public CodeTemplateEPC forCount() {
            type = "COUNT";
            return this;
        }

        public CodeTemplateEPC sub() {
            return new CodeTemplateEPC(this);
        }

        public CodeTemplateEPC complete(boolean and) {
            finish(and);
            return parent == null ? this : (CodeTemplateEPC) parent;
        }

        public CodeTemplateFPC toFlex() {
            CodeTemplateFPC flex = new CodeTemplateFPC();
            flex.setUpdateSqlList(updateSqlList);
            flex.setUpdateValueList(updateValueList);
            flex.setSqlList(sqlList);
            flex.setValueList(valueList);
            flex.setType(type);
            return flex;
        }

        public Condition toCondition() {
            return toCondition(CodeTemplate.class, "cm_code_template");
        }

        // field epc auto
// #bind.field.id#
        public Id id() {
            return new Id();
        }

        // #bind.field.createBy#
        public CreateBy createBy() {
            return new CreateBy();
        }
// $bind.field.id$

        // #bind.field.updateBy#
        public UpdateBy updateBy() {
            return new UpdateBy();
        }

        // #bind.field.createTime#
        public CreateTime createTime() {
            return new CreateTime();
        }
// $bind.field.createBy$

        // #bind.field.updateTime#
        public UpdateTime updateTime() {
            return new UpdateTime();
        }

        // #bind.field.codeName#
        public CodeName codeName() {
            return new CodeName();
        }
// $bind.field.updateBy$

        // #bind.field.prefix#
        public Prefix prefix() {
            return new Prefix();
        }

        // #bind.field.codeDateTimeFormat#
        public CodeDateTimeFormat codeDateTimeFormat() {
            return new CodeDateTimeFormat();
        }
// $bind.field.createTime$

        // #bind.field.initValue#
        public InitValue initValue() {
            return new InitValue();
        }

        // #bind.field.minStep#
        public MinStep minStep() {
            return new MinStep();
        }
// $bind.field.updateTime$

        // #bind.field.maxStep#
        public MaxStep maxStep() {
            return new MaxStep();
        }

        // #bind.field.fixLength#
        public FixLength fixLength() {
            return new FixLength();
        }
// $bind.field.codeName$

        public class Id extends LongEPCField<CodeTemplateEPC> {
            private Id() {
                super(CodeTemplateEPC.this, "id", id);
            }
        }

        public class CreateBy extends StringEPCField<CodeTemplateEPC> {
            private CreateBy() {
                super(CodeTemplateEPC.this, "create_by", createBy);
            }
        }
// $bind.field.prefix$

        public class UpdateBy extends StringEPCField<CodeTemplateEPC> {
            private UpdateBy() {
                super(CodeTemplateEPC.this, "update_by", updateBy);
            }
        }

        public class CreateTime extends LocalDateTimeEPCField<CodeTemplateEPC> {
            private CreateTime() {
                super(CodeTemplateEPC.this, "create_time", createTime);
            }
        }
// $bind.field.codeDateTimeFormat$

        public class UpdateTime extends LocalDateTimeEPCField<CodeTemplateEPC> {
            private UpdateTime() {
                super(CodeTemplateEPC.this, "update_time", updateTime);
            }
        }

        public class CodeName extends StringEPCField<CodeTemplateEPC> {
            private CodeName() {
                super(CodeTemplateEPC.this, "code_name", codeName);
            }
        }
// $bind.field.initValue$

        public class Prefix extends StringEPCField<CodeTemplateEPC> {
            private Prefix() {
                super(CodeTemplateEPC.this, "prefix", prefix);
            }
        }

        public class CodeDateTimeFormat extends StringEPCField<CodeTemplateEPC> {
            private CodeDateTimeFormat() {
                super(CodeTemplateEPC.this, "code_date_time_format", codeDateTimeFormat);
            }
        }
// $bind.field.minStep$

        public class InitValue extends IntegerEPCField<CodeTemplateEPC> {
            private InitValue() {
                super(CodeTemplateEPC.this, "init_value", initValue);
            }
        }

        public class MinStep extends IntegerEPCField<CodeTemplateEPC> {
            private MinStep() {
                super(CodeTemplateEPC.this, "min_step", minStep);
            }
        }
// $bind.field.maxStep$

        public class MaxStep extends IntegerEPCField<CodeTemplateEPC> {
            private MaxStep() {
                super(CodeTemplateEPC.this, "max_step", maxStep);
            }
        }

        public class FixLength extends IntegerEPCField<CodeTemplateEPC> {
            private FixLength() {
                super(CodeTemplateEPC.this, "fix_length", fixLength);
            }
        }
// $bind.field.fixLength$

    }
}
